package me.helllp.book.concurrent.ch03;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * 周期任务线程池
 * 
 * @author Administrator
 *
 */
public class ScheduledExecutorServiceDemo {
	public static void main(String[] args) {
		ScheduledExecutorService ses = Executors.newScheduledThreadPool(10);
		
		//	如果前面的任务没有调度完成，不会被启动
		ses.scheduleAtFixedRate(new Runnable() {
			
			@Override
			public void run() {
				try {
					Thread.sleep(1000);
					System.out.println(System.currentTimeMillis() / 1000);
				} catch (Exception e) {
					// TODO: handle exception
				}
			}
		}, 0, 2, TimeUnit.SECONDS);
	}
}
